package com.sense.kukoo.biz_explore.adapter.provider

import android.widget.TextView
import com.sense.kukoo.biz_explore.adapter.SearchAdapter
import com.sense.kukoo.common.R
import com.sense.kukoo.common.repo.bean.SearchBean
import com.sense.kukoo.common.wiget.adapter.provider.MultiItemProvider
import com.sense.kukoo.common.wiget.adapter.viewholder.BaseViewHolder

class RecentItemProvider(val listener: SearchAdapter.SearchEventListener):
    MultiItemProvider<SearchBean>() {
    override fun getItemType(): Int = SearchBean.TYPE_RECENT_ITEM

    override fun getItemLayoutId(): Int = R.layout.common_search_recent_item

    override fun onBindViewHolder(viewHolder: BaseViewHolder, item: SearchBean) {
        val tv_recent = viewHolder.getView(R.id.tv_recent) as TextView
        tv_recent.setText(item.keyword)
        //
        tv_recent.setOnClickListener {
            listener.onRecentItemClick(item)
        }
        viewHolder.getView(R.id.iv_recent_delete).setOnClickListener {
            listener.onRecentItemDelete(item)
        }
    }
}